<?php
/**
 * Created by PhpStorm.
 * User: kongjg
 * Date: 16/8/12
 * Time: 下午5:44
 */
class db{
//    private $dsn = 'mysql:host=118.193.238.118;dbname=leiyier1_db';
//    private  $userName = 'leiyier1_db';
//    private $passWord = 'zhu0601qing';

    private function contactDB(){
        try {
            $dbh = new PDO('mysql:host=118.193.238.118;dbname=leiyier1_db','leiyier1_db','zhu0601qing');
            if($dbh){
                echo 'success';
                return $dbh;
            }
        }catch (PDOException $e){
            die ('error:'.$e->getMessage().'<br/>');
        }
        return $dbh;
    }

     function get($attr,$tableName){
        $dbh = $this->contactDB();
          $dbh->query('SELECT '.$attr.' FROM '.$tableName);
    }

   public function put($tableName){
        $dbh = $this->contactDB();
        $dbh->query('CREATE TABLE IF NOT EXISTS '.$tableName);
        try{
            $dbh->query('INSERT INTO '.$tableName.
                '(l_id,l_title,l_desc)'.
                'VALUES '.
                '("id1","title1","desc1")'
            );
        }catch (PDOException $e){
            die ('error:'.$e->getMessage().'<br/>');
        }
    }
    function del(){

    }

}



